/*
* Copyright (c) 2016 ShopJsp. All Rights Reserved.
 * ============================================================================
 * 版权所有 2011 - 今 北京华宇盈通科技有限公司，并保留所有权利。
 * ----------------------------------------------------------------------------
 * 提示：在未取得SHOPJSP商业授权之前，您不能将本软件应用于商业用途，否则SHOPJSP将保留追究的权力。
 * ----------------------------------------------------------------------------
 * 官方网站：http://www.shopjsp.com
 * ============================================================================
*/
package com.hyyt.shopjsp.basic.service.imp;

import com.hyyt.shopjsp.basic.dao.BasicUserActorDAO;
import com.hyyt.shopjsp.basic.pojo.BasicUserActor;
import com.hyyt.shopjsp.basic.service.IBasicUserActorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import org.apache.log4j.Logger;
/**
* basic_userActor, BASIC_管理员角色表
 *
 * @author Robot 14-5-7 上午10:19
 */
@Service
public class BasicUserActorService implements IBasicUserActorService {
    private static  final Logger logger = Logger.getLogger(IBasicUserActorService.class);

    @Resource
    private BasicUserActorDAO basicUserActorDAO;

    /**
     * 保存BASIC_管理员角色表
     *
     * @param usersId
     * @param actorIds  角色id 拼串字符
     * @param actorNames  角色名称 拼串字符
     */
    @Override
    public void saveBasicUserActor(Integer usersId, String actorIds,String actorNames) {
        String [] actorIdsStr=actorIds.split(",");
        String [] actorNamesStr=actorNames.split(",");
        for (int i=0; i< actorIdsStr.length;i++) {
            BasicUserActor basicUserActor = new BasicUserActor();
            basicUserActor.setUsersId(usersId);
            basicUserActor.setActorId(Integer.parseInt(actorIdsStr[i]));
            basicUserActor.setActorName(actorNamesStr[i]);
            basicUserActorDAO.insert(basicUserActor);
        }
    }


    /**
     * 删除指定ID的BASIC_管理员角色表
     *
     * @param usersId 管理员id
     * @param actorId 角色id
     */
    @Override
    public void deleteBasicUserActor(Integer usersId, Integer actorId) {
        Map<String, Object> param = new HashMap<>();
        param.put("usersId",usersId);
        param.put("actorId",actorId);
        basicUserActorDAO.delete("deleteBasicUserActor",param);
    }

    /**
     * 统计BASIC_管理员角色表
     *
     * @param params 查询参数
     * @return 结果集记录数
     */
    @Override
    public  int countBasicUserActor(Map<String, Object> params){
       return  basicUserActorDAO.count(params);
    }


}
